<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .div1 {
            width: 100px;
            height: 100px;
            margin-top: 20px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="div">
        <!-- <button v-on:click="isShow = !isShow">toggle</button> -->
        <button @click="toggle">toggle</button>
        <div v-if="isShow" class="div1"></div>
        <hr>
        <p>v-text指令</p>
        <div v-text="msg"></div>
        <div>{{msg}}</div>
        <hr>
        <p>v-html指令</p>
        <div v-text="info"></div>
        <div v-html="info"></div>
    </div>
    <script src="../vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#div',
            data: {
                // 控制方块显示隐藏
                isShow: false,
                msg: 'hello',
                info: '<h1>hello</h1>'
            },
            methods: {
                toggle() {
                    // 不要直接操作dom vue中都是通过变量的改变间接操作dom
                    this.isShow = !this.isShow;
                }
            }
        })
    </script>
</body>
</html>